Public Class HISBUYPRODUCT
    Dim connect As CONDB = CONDB.NewConnection()
    Dim objSelectDatahis As New MASPRODUCT2

    Private Sub HISBUYPRODUCT_Load(sender As Object, e As EventArgs) Handles Me.Load
        SelectHis()
    End Sub
    Private Sub SelectHis()
        Dim his As DataTable
        his = connect.GetTable(objSelectDatahis.SelectHis_)
        AGENTGrid.PrimaryGrid.DataSource = his
    End Sub

    Private Sub ButtonX1_Click(sender As Object, e As EventArgs) Handles ButtonX1.Click
        If RadioButton2.Checked = True Then
            Dim NextFrm As New PRINT2(objSelectDatahis.SelectHis_)
            NextFrm.Show()
        ElseIf RadioButton1.Checked = True Then
            Dim NextFrm As New PRINT2(objSelectDatahis.SelectHisDate(DateTimePicker1.Value, DateTimePicker2.Value))
            NextFrm.Show()
        End If
    End Sub

    Private Sub ButtonX2_Click(sender As Object, e As EventArgs) Handles ButtonX2.Click
        If RadioButton2.Checked = True Then
            SelectHis()
        ElseIf RadioButton1.Checked = True Then
            SelectHisDate(DateTimePicker1.Value, DateTimePicker2.Value)
        End If
    End Sub

    Private Sub SelectHisDate(ByVal date1 As Date, ByVal date2 As Date)
        Dim his As DataTable
        his = connect.GetTable(objSelectDatahis.SelectHisDate2(date1, date2))
        AGENTGrid.PrimaryGrid.DataSource = his
    End Sub
End Class